#ifndef DEDUP_H
#define DEDUP_H

#include <string>
#include <vector>

#include <ctime>

#include "filenode.h"
#include "hash.h"


class dedup
{
public:
    /* path to deduplication dir */
    dedup(std::string &path);

    virtual ~dedup();

    /* start deduplication analyze */
    void run();

    /* gets count analyze files */
    long long int get_count_files() const;

    /* gets total size files in byte */
    long long int get_total_size() const;

    /* gets duplication filesize */
    long long int get_dedup_size() const;

    /* gets speed to process deduplication */
    float get_processing_speed() const;

private:
    void sort();                                        /* sort files by size */
    void dedup_files();                                 /* deduplication by size */
    void duplicate(std::vector<filenode> &cmp);         /* deduplication by sha-512 hash */

    std::string abs_path;                   /* root dir */
    std::vector<filenode> nodes;            /* list files to dir */
    time_t start_time;                      /* start time alalyze */

    long long int total_size;               /* total filesize */
    long long int dedup_size;               /* deduplication filesize */
};

#endif // DEDUP_H
